/* 
 * cms，一个基于J2EE架构内容管理系统
 * Copyright © GrayRabbit Co., Ltd. All rights reserved.
 * Department:运营department
 * 更多信息请访问：
 * http://code.google.com/p/gray-rabbit-cms/
 */
package org.grayrabbit.cms.action.content;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Random;

import org.apache.commons.lang.StringUtils;
import org.apache.struts2.convention.annotation.Action;
import org.apache.struts2.convention.annotation.Result;
import org.apache.struts2.convention.annotation.ResultPath;
import org.grayrabbit.cms.constant.ConfigCode;
import org.grayrabbit.cms.constant.ConstantWebApp;
import org.grayrabbit.cms.constant.ContentStatic;
import org.grayrabbit.cms.constant.DictionaryStaticValues;
import org.grayrabbit.cms.entity.Admin;
import org.grayrabbit.cms.entity.Content;
import org.grayrabbit.cms.entity.ContentAttach;
import org.grayrabbit.cms.entity.FlashContent;
import org.grayrabbit.cms.entity.PictureContent;
import org.grayrabbit.cms.entity.SoftwareContent;
import org.grayrabbit.cms.entity.VideoContent;
import org.grayrabbit.cms.service.content.ContentAttachService;
import org.grayrabbit.cms.service.content.ContentService;
import org.grayrabbit.cms.service.content.FlashContentService;
import org.grayrabbit.cms.service.content.PictureContentService;
import org.grayrabbit.cms.service.content.SoftwareContentService;
import org.grayrabbit.cms.service.content.VideoContentService;
import org.grayrabbit.cms.service.system.ConfigService;
import org.grayrabbit.cms.util.DateUtil;
import org.grayrabbit.cms.util.FilePathSptUtil;
import org.grayrabbit.cms.util.FileUtil;
import org.grayrabbit.cms.util.UploadUtil;
import org.grayrabbit.cms.util.ZipUtil;
import org.grayrabbit.cms.vo.content.ContentAttachBean;
import org.grayrabbit.cms.vo.content.ContentBean;
import org.grayrabbit.cms.vo.content.FlashContentBean;
import org.grayrabbit.cms.vo.content.PictureContentBean;
import org.grayrabbit.cms.vo.content.SoftwareContentBean;
import org.grayrabbit.cms.vo.content.VideoContentBean;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import org.grayrabbit.dao.util.Page;
import org.grayrabbit.web.struts2.GenericAction;

/**
 * <b>ContentAttachAction</b> Struts2 action�?
 * 
 * @version 1.0,创建时间:2011-05-16 16:40:00
 */
@Controller
@Scope("prototype")
@ResultPath("/WEB-INF/content/content")
public class ContentAttachAction extends GenericAction<ContentAttachBean> {
	private static final long serialVersionUID = -1L;
	private static Logger log = LoggerFactory
			.getLogger(ContentAttachAction.class);
	public static final int ITEM_NUM = -1;
	private static final String SPT = File.separator;
	// Service接口接入
	@Autowired
	@Qualifier("contentAttachServiceImpl")
	private ContentAttachService contentAttachService;

	@Autowired
	@Qualifier("contentServiceImpl")
	private ContentService contentService;

	@Autowired
	@Qualifier("flashContentServiceImpl")
	private FlashContentService flashContentService;

	@Autowired
	@Qualifier("videoContentServiceImpl")
	private VideoContentService videoContentService;

	@Autowired
	@Qualifier("pictureContentServiceImpl")
	private PictureContentService pictureContentService;

	@Autowired
	@Qualifier("softwareContentServiceImpl")
	private SoftwareContentService softwareContentService;

	@Autowired
	@Qualifier("configServiceImpl")
	private ConfigService configService;
	
	// VO对象，由前端页面数据组装
	private ContentAttachBean contentAttach;
	private ContentBean content;
	private FlashContentBean flashContent;
	private VideoContentBean videoContent;
	private PictureContentBean pictureContent;
	private SoftwareContentBean softwareContent;
	private String uploadType;
	private String flag;
	private String attachId;
	private String contentId;
	private String uploadUrl = FilePathSptUtil.UPLOAD_URL;
	private String pictureDbPath;  //图片数据库
	private String picturePhysicalPath;// 物理路径
	
	public String getUploadUrl() {
		return uploadUrl;
	}

	public void setUploadUrl(String uploadUrl) {
		this.uploadUrl = uploadUrl;
	}

	public String getFlag() {
		return flag;
	}

	public void setFlag(String flag) {
		this.flag = flag;
	}

	public String getUploadType() {
		return uploadType;
	}

	public void setUploadType(String uploadType) {
		this.uploadType = uploadType;
	}

	public FlashContentBean getFlashContent() {
		return flashContent;
	}

	public void setFlashContent(FlashContentBean flashContent) {
		this.flashContent = flashContent;
	}

	public VideoContentBean getVideoContent() {
		return videoContent;
	}

	public void setVideoContent(VideoContentBean videoContent) {
		this.videoContent = videoContent;
	}

	public PictureContentBean getPictureContent() {
		return pictureContent;
	}

	public void setPictureContent(PictureContentBean pictureContent) {
		this.pictureContent = pictureContent;
	}

	public SoftwareContentBean getSoftwareContent() {
		return softwareContent;
	}

	public void setSoftwareContent(SoftwareContentBean softwareContent) {
		this.softwareContent = softwareContent;
	}

	public ContentBean getContent() {
		return content;
	}

	public void setContent(ContentBean content) {
		this.content = content;
	}

	/** return 前端页面数据组装VO对象,<b>ContentAttachBean</b> */
	public ContentAttachBean getContentAttach() {
		return contentAttach;
	}

	public void setContentAttach(ContentAttachBean contentAttach) {
		this.contentAttach = contentAttach;
	}

	public File getUpload() {
		return upload;
	}

	public void setUpload(File upload) {
		this.upload = upload;
	}

	
	public String getPictureDbPath() {
		return pictureDbPath;
	}

	public void setPictureDbPath(String pictureDbPath) {
		this.pictureDbPath = pictureDbPath;
	}

	public String getPicturePhysicalPath() {
		return picturePhysicalPath;
	}

	public void setPicturePhysicalPath(String picturePhysicalPath) {
		this.picturePhysicalPath = picturePhysicalPath;
	}



	// 分页对象
	private Page<ContentAttach> page = new Page<ContentAttach>(MAX_PAGE_NUM,
			true);

	/*
	 * return分页对象，默认实例化。如：page.pageNu=2,将更新相应的对象property
	 */
	public Page<ContentAttach> getPage() {
		return page;
	}

	// 接收前端form,url提交参数组装成分页property
	public void setPage(Page<ContentAttach> page) {
		this.page = page;
	}

	private String url;
	private String tempUrl;
	private String control;
	private Integer percent = 0;
	public static final int BUFFER_SIZE = 20 * 1024;
	private File upload;
	private File uploadp;

	public File getUploadp() {
		return uploadp;
	}

	public void setUploadp(File uploadp) {
		this.uploadp = uploadp;
	}

	public String getUrl() {
		return url;
	}

	public void setUrl(String url) {
		this.url = url;
	}

	public String getControl() {
		return control;
	}

	public void setControl(String control) {
		this.control = control;
	}

	public String getTempUrl() {
		return tempUrl;
	}

	public void setTempUrl(String tempUrl) {
		this.tempUrl = tempUrl;
	}

	public Integer getPercent() {
		return percent;
	}

	public void setPercent(Integer percent) {
		this.percent = percent;
	}

	class UploadThread implements Runnable {
		// 在当前线程中上传的文件.
		private File from;
		// 保存到服务器硬盘上的位置.
		private File to;

		// 构造方法，用来传址.
		public UploadThread(File src, File dst) {
			this.from = src;
			this.to = dst;
		}

		// 线程中处理上传.
		public void run() {
			copy(from, to);
		}

	}

	protected void copy(File src, File dst) {
		InputStream in = null;
		OutputStream out = null;
		try {
			in = new BufferedInputStream(new FileInputStream(src), BUFFER_SIZE);
			out = new BufferedOutputStream(new FileOutputStream(dst),
					BUFFER_SIZE);
			byte[] buffer = new byte[BUFFER_SIZE];
			int len = 0;
			while ((len = in.read(buffer)) > 0) {
				out.write(buffer, 0, len);
				out.flush();
				Thread.sleep(30);
				ContentAttachBean contentAttach = (ContentAttachBean) ContentStatic.cab
						.get("contentAttach");
				// 计算已传多少
				contentAttach.setUploaded(contentAttach.getUploaded() + len);
				// 计算上传百分比
				contentAttach
						.setPercent((int) (contentAttach.getUploaded() * 100 / contentAttach
								.getAttachSize()));
				ContentStatic.cab.put(contentAttach.getContent().getContentId(),
						contentAttach);
			}
		} catch (Exception e) {
		} finally {
			if (null != in) {
				try {
					in.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			if (null != out) {
				try {
					out.close();
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
		}
	}

	@Action(value = "contentattach-ajaxRequest", results = {
			@Result(name = "percentAjax", location = "/common/upload/percent-ajax.jsp"),
			@Result(name = "successAjax", location = "/common/upload/upload-ajax.jsp"),
			@Result(name = "showAjax", location = "/common/upload/show-ajax.jsp") })
	public String ajaxRequest() {
		if (control.equals("listFile")) {
			if (contentAttach != null
					&& contentAttach.getContent() != null
					&& StringUtils.isNotBlank(contentAttach.getContent()
							.getContentId())) {
				page.setPageSize(-1);
				contentAttachService.list(page, contentAttach);
				contentAttach.setContentType(flag);
			}
		} else if (control.equals("addFile")) {
			page.setPageSize(-1);
			contentAttachService.list(page, contentAttach);
			contentAttach = ContentStatic.cab.get(contentAttach.getContent().getContentId());
		} else if (control.equals("delFile")) {
			// 删除文件
			if (contentAttach.getAttachId().split(",").length > 0) {
				for (int i = 0; i < contentAttach.getAttachId().split(",").length; i++) {
					ContentAttach caitem = contentAttachService
							.getContentAttach(contentAttach.getAttachId()
									.split(",")[i]);
					String fileUrl = caitem.getAttachUrl();
					FileUtil.delFile(fileUrl);// 删除文件夹中的文件
					contentAttachService.delete(caitem);
				}
			} else {
				ContentAttach caitem = contentAttachService
						.getContentAttach(contentAttach.getAttachId());
				String fileUrl = caitem.getAttachUrl();
				FileUtil.delFile(fileUrl);// 删除文件夹中的文件
				contentAttachService.delete(caitem); // 删除数据库文件
			}
		} else if (control.equals("emptyFile")) {
			// FileUtil.delAllFile(fileUrl);
			// 删除所有附件
			contentAttachService.list(page, contentAttach);
		}
		return "showAjax";
	}

	@Action(value = "contentattach-iframeRequest", results = {
			@Result(name = "percentAjax", location = "/common/upload/percent-ajax.jsp"),
			@Result(name = "successAjax", location = "/common/upload/upload-ajax.jsp"),
			@Result(name = "showAjax", location = "/common/upload/show-ajax.jsp") })
	public String iframeRequest() {
		ContentAttachBean obj = (ContentAttachBean) ContentStatic.cab.get(contentAttach
				.getContent().getContentId());
		if (obj != null) {
			// 根据服务器的文件保存地址和原文件名创建目录文件全路径
			File dstFile = new File(obj.getAttachUrl());
			File dirFile = new File(obj.getContentAttachRealPath());
			boolean isDir = dirFile.isDirectory();
			if (!isDir) {// 目录不存在则先建目录
				try {
					dirFile.mkdirs();
				} catch (Exception e) {
					log.debug(e.toString());
				}
			}
			InputStream in = null;
			OutputStream out = null;
			try {
				in = new BufferedInputStream(new FileInputStream(upload),
						BUFFER_SIZE);
				out = new BufferedOutputStream(new FileOutputStream(dstFile),
						BUFFER_SIZE);
				byte[] buffer = new byte[BUFFER_SIZE];
				int len = 0;
				while ((len = in.read(buffer)) > 0) {
					out.write(buffer, 0, len);
					out.flush();
					Thread.sleep(30);
					// 计算已传多少
					obj.setUploaded(obj.getUploaded() + len);
					// 计算上传百分比
					obj.setPercent((int) (obj.getUploaded() * 100 / FileUtil
							.getFileSize(upload.getPath())));
					ContentStatic.cab.put(obj.getContent().getContentId(), obj);
				}
			} catch (Exception e) {
				log.debug(e.toString());
			} finally {
				if (null != in) {
					try {
						in.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
				if (null != out) {
					try {
						out.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			}
		}
		log.info(obj.getContentAttachRealPath());
		String fileName = obj.getUploadName();
		ContentAttach ca = contentAttachService.getContentAttach(obj
				.getAttachId());
		ca.setAttachType("0");
		ca.setAttachDownloadNum(null);
		contentAttachService.save(ca);
		doPic(fileName,obj,ca);
		return "percentAjax";
	}
	
	private void doPic(String fileName,ContentAttachBean obj,ContentAttach ca){
		File spic = null;
		File mpic = null;
		File bpic = null;
		if(configService.getConfigByAttrKey(ConfigCode.PIC_TYPE)!=null&&UploadUtil.isPic(obj.getContentAttachRealPath()+fileName,configService.getConfigByAttrKey(ConfigCode.PIC_TYPE).getConfigAttrValue())){
			spic = UploadUtil.dealWithPic(
					obj.getContentAttachRealPath(),
					obj.getContentAttachRealPath(),
					fileName,
					fileName.substring(0, fileName.lastIndexOf("."))
							+ "_"
							+ configService.getConfigByAttrKey(
									ConfigCode.PIC_S).getConfigAttrValue()
							+ "." + obj.getAttachExt(),
					Integer.parseInt(configService
							.getConfigByAttrKey(ConfigCode.PIC_S)
							.getConfigAttrValue().split("_")[0]),
					Integer.parseInt(configService
							.getConfigByAttrKey(ConfigCode.PIC_S)
							.getConfigAttrValue().split("_")[1]));
			mpic = UploadUtil.dealWithPic(
					obj.getContentAttachRealPath(),
					obj.getContentAttachRealPath(),
					fileName,
					fileName.substring(0,fileName.lastIndexOf("."))
							+ "_"
							+ configService.getConfigByAttrKey(ConfigCode.PIC_M)
									.getConfigAttrValue() + "."
							+ obj.getAttachExt(), Integer.parseInt(configService
							.getConfigByAttrKey(ConfigCode.PIC_M)
							.getConfigAttrValue().split("_")[0]),Integer.parseInt(
							configService.getConfigByAttrKey(ConfigCode.PIC_M)
									.getConfigAttrValue().split("_")[1]));
			bpic = UploadUtil.dealWithPic(
					obj.getContentAttachRealPath(),
					obj.getContentAttachRealPath(),
					fileName,
					fileName.substring(0, fileName.lastIndexOf("."))
							+ "_"
							+ configService.getConfigByAttrKey(ConfigCode.PIC_B)
									.getConfigAttrValue() + "."
							+ obj.getAttachExt(), Integer.parseInt(configService
							.getConfigByAttrKey(ConfigCode.PIC_B)
							.getConfigAttrValue().split("_")[0]),Integer.parseInt(
							configService.getConfigByAttrKey(ConfigCode.PIC_B)
									.getConfigAttrValue().split("_")[1]));
		}
		if(spic!=null&&mpic!=null&&bpic!=null&&UploadUtil.isPic(obj.getContentAttachRealPath()+fileName,configService.getConfigByAttrKey(ConfigCode.PIC_TYPE).getConfigAttrValue())){
			saveOtherTypePic(ca.getContent(),fileName,ca.getAttachExt(),ca.getAttachUrl(),spic,mpic,bpic);
		}
	}

	private void saveOtherTypePic(Content content, String fileName,
			String attachExt, String attachUrl, File spic, File mpic, File bpic) {
		ContentAttach ca1 = new ContentAttach();
		ContentAttach ca2 = new ContentAttach();
		ContentAttach ca3 = new ContentAttach();
		ca1.setContent(content);
		ca2.setContent(content);
		ca3.setContent(content);
		ca1.setAttachName(fileName.substring(0, fileName.lastIndexOf("."))+ "_"+ configService.getConfigByAttrKey(ConfigCode.PIC_S).getConfigAttrValue() + "."+ attachExt);
		ca1.setAttachType("1");
		ca1.setAttachSize(FileUtil.getFileSize(spic.getPath())/1024);
		ca1.setAttachUrl(attachUrl.substring(0, attachUrl.lastIndexOf("/")+1)+ca1.getAttachName());
		ca1.setAttachExt(attachExt);
		contentAttachService.save(ca1);
		ca2.setAttachName(fileName.substring(0, fileName.lastIndexOf("."))+ "_"+ configService.getConfigByAttrKey(ConfigCode.PIC_M).getConfigAttrValue() + "."+ attachExt);
		ca2.setAttachType("2");
		ca2.setAttachSize(FileUtil.getFileSize(mpic.getPath())/1024);
		ca2.setAttachUrl(attachUrl.substring(0, attachUrl.lastIndexOf("/")+1)+ca2.getAttachName());
		ca2.setAttachExt(attachExt);
		contentAttachService.save(ca2);
		ca3.setAttachName(fileName.substring(0, fileName.lastIndexOf("."))+ "_"+ configService.getConfigByAttrKey(ConfigCode.PIC_B).getConfigAttrValue() + "."+ attachExt);
		ca3.setAttachType("3");
		ca3.setAttachSize(FileUtil.getFileSize(bpic.getPath())/1024);
		ca3.setAttachUrl(attachUrl.substring(0, attachUrl.lastIndexOf("/")+1)+ca3.getAttachName());
		ca3.setAttachExt(attachExt);
		contentAttachService.save(ca3);
	}

	@Action(value = "contentattach-returnValue", results = {
			@Result(name = "percentAjax", location = "/common/upload/percent-ajax.jsp"),
			@Result(name = "successAjax", location = "/common/upload/upload-ajax.jsp"),
			@Result(name = "showAjax", location = "/common/upload/show-ajax.jsp") })
	public String returnValue() {
		try {
			Thread.sleep(200);
		} catch (InterruptedException e) {
			e.printStackTrace();
		}
		contentAttach = (ContentAttachBean) ContentStatic.cab.get(contentAttach.getContent()
				.getContentId());
		if (contentAttach != null) {
			if (contentAttach.getPercent() == 100) {
				return "successAjax";
			}
		}
		return "percentAjax";
	}

	/**
	 * 在执行（struts2的action调用时）list()方法前执行本方法
	 */
	public void prepareList() {
		prepareModel();
	}

	/**
	 * 在执行任何其它action方法（struts2的action调用时）前执行本方法
	 */
	public void prepare() {
		if (contentAttach == null) {
			contentAttach = new ContentAttachBean();
		}
	}

	/**
	 * 实现ModelDriven的接口简例前端页的bean组装写法, 如：
	 * 
	 * <pre>
	 * 	<code> name="user.userName"</code>
	 * 改写成：
	 * 	<code> name="userName"</code>
	 * action实例中，会自动组成user成员变量
	 * </pre>
	 */
	public ContentAttachBean getModel() {
		return contentAttach;
	}

	@Override
	protected void prepareModel() {
		if (contentAttach != null
				&& StringUtils.isNotBlank(contentAttach.getAttachId())) {
			contentAttach = (ContentAttachBean) dozer.map(contentAttachService
					.getContentAttach(contentAttach.getAttachId()),
					ContentAttachBean.class);
		}
	}

	/**
	 * 删除<b>ContentAttach</b>记录的方法，成员变量<b>key</b>为主键的String数组，以主键方式进行删作
	 * 删除成功后，返回"reload"，然后跳转到contentattach-list.action
	 */
	@Override
	@Action(value = "contentattach-delete", results = { @Result(name = "reload", type = "redirectAction", params = {
			"actionName", "contentattach-list" }) })
	public String delete() {
		contentAttachService.delete(key);
		return RELOAD;
	}

	/**
	 * ContentAttach的列表方法，通过成员变量<b>page�?{insClassName}</b>调用service接口，更新page
	 * 执行成功后，将映射到contentattach-list.jsp页面
	 */
	@Override
	@Action(value = "contentattach-list")
	public String list() {
		contentAttachService.list(page, contentAttach);
		return SUCCESS;
	}

	/**
	 * ContentAttach的新增与编辑的方法执行成功能 将映射到contentattach-input.jsp
	 */
	@Action(value = "contentattach-input")
	public String input() {
		prepareModel();
		return SUCCESS;
	}

	/**
	 * save or update ContentAttach的方法，将成员property
	 * contentAttach转成ContentAttach实例，执行保存；
	 * 执行成功后，返回"reload"，然后跳转到contentattach-list.action
	 */
	@Override
	@Action(value = "contentattach-save", results = { @Result(name = "redirect", location = "/common/upload/contentattach-save.jsp"),@Result(name = "input", location = "/common/upload/error-ajax.jsp") })
	public String save() {
		if (!StringUtils.isNotBlank(content.getContentId())) {
			content.setContentId(null);
			content.setContentStatus(DictionaryStaticValues.CONTENT_STATUS_LOCK);
			Content cobj = (Content) dozer.map(content, Content.class);
			contentService
					.save(cobj,
							(Admin) getSessionValue(ConstantWebApp.CURRENT_ADMIN),
							null);
			content.setContentId(cobj.getContentId());
		} else {
			content = (ContentBean) dozer.map(
					contentService.getContent(content.getContentId()),
					ContentBean.class);
		}
		if (url != null && !url.equals("")) {
			try {
				url = new String(url.getBytes("iso-8859-1"), "utf-8");
			} catch (UnsupportedEncodingException e2) {
				log.info(e2.toString());
			}
			tempUrl = url.substring(url.lastIndexOf("\\") + 1, url.length());
		}
		String fileType = FileUtil.getFileExt(tempUrl);
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMM");
		SimpleDateFormat sdf2 = new SimpleDateFormat("dd");
		contentAttach.setAttachMemo(null);
		contentAttach.setAttachName(tempUrl);
		contentAttach.setAttachExt(fileType);
		contentAttach.setAttachSize((int) (upload.length() / 1024));
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
		Random roll = new Random();
		String savePath = FilePathSptUtil.CONTENT_OTHER
				+ FilePathSptUtil.padRightAndLeftSpt(sdf1.format(new Date()))
				+ sdf2.format(new Date());
		String uploadName = sdf.format(new Date()) + roll.nextInt(10) + "." + fileType;
		contentAttach.setUploadName(uploadName);
		contentAttach.setAttachUrl((FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padRightAndLeftSpt(savePath)
				+ uploadName).replaceAll("\\\\", "/"));
		contentAttach.setContentAttachRealPath(FilePathSptUtil.UPLOAD_ROOT_PATH
				+ FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padRightAndLeftSpt(savePath));
		contentAttach.setContent(content);
		contentAttach.setContentType(DictionaryStaticValues.CONTENT_CONTENT);
		contentAttach.setAttachDownloadNum(ITEM_NUM);
		contentAttach.setUploaded(1);
		contentAttach.setAttachType("0");
		ContentAttach caobj = (ContentAttach) dozer.map(contentAttach,
				ContentAttach.class);
		caobj.setContent((Content) dozer.map(content, Content.class));
		contentAttachService.save(caobj);
		contentAttach.setAttachId(caobj.getAttachId());
		contentAttach.setAttachUrl((FilePathSptUtil.UPLOAD_ROOT_PATH
				+ FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padRightAndLeftSpt(savePath)
				+ uploadName).replaceAll("\\\\", "/"));
		if (ContentStatic.cab == null) {
			ContentStatic.cab = new HashMap<String, ContentAttachBean>();
		}
		ContentStatic.cab.put(contentAttach.getContent().getContentId(), contentAttach);
		return "redirect";
	}

	@Action(value = "contentattach-saveflash", results = { @Result(name = "redirect", location = "/common/upload/contentattach-save.jsp"),@Result(name = "input", location = "/common/upload/error-ajax.jsp") })
	public String saveflash() {
		if (!StringUtils.isNotBlank(flashContent.getContentId())) {
			flashContent.setContentId(null);
			flashContent
					.setContentStatus(DictionaryStaticValues.CONTENT_STATUS_LOCK);
			FlashContent cobj = (FlashContent) dozer.map(flashContent,
					FlashContent.class);
			flashContentService
					.save(cobj,
							(Admin) getSessionValue(ConstantWebApp.CURRENT_ADMIN),
							null);
			flashContent.setContentId(cobj.getContentId());
		} else {
			flashContent = (FlashContentBean) dozer.map(flashContentService
					.getFlashContent(flashContent.getContentId()),
					FlashContentBean.class);
		}
		if (url != null && !url.equals("")) {
			try {
				url = new String(url.getBytes("iso-8859-1"), "utf-8");
			} catch (UnsupportedEncodingException e2) {
				log.info(e2.toString());
			}
			tempUrl = url.substring(url.lastIndexOf("\\") + 1, url.length());
		}
		String fileType = FileUtil.getFileExt(tempUrl);
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMM");
		SimpleDateFormat sdf2 = new SimpleDateFormat("dd");
		contentAttach.setAttachMemo(null);
		contentAttach.setAttachName(tempUrl);
		contentAttach.setAttachExt(fileType);
		contentAttach.setAttachSize((int) (upload.length() / 1024));
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
		Random roll = new Random();
		String savePath = FilePathSptUtil.CONTENT_FLASH
				+ FilePathSptUtil.padRightAndLeftSpt(sdf1.format(new Date()))
				+ sdf2.format(new Date());
		contentAttach.setAttachUrl(FilePathSptUtil.UPLOAD_ROOT_PATH
				+ FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padRightAndLeftSpt(savePath)
				+ sdf.format(new Date()) + roll.nextInt(10) + "." + fileType);
		contentAttach.setContentAttachRealPath(FilePathSptUtil.UPLOAD_ROOT_PATH
				+ FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padLeftSpt(savePath));
		ContentAttach caobj = (ContentAttach) dozer.map(contentAttach,
				ContentAttach.class);
		caobj.setContent((FlashContent) dozer.map(flashContent,
				FlashContent.class));
		contentAttachService.save(caobj);
		contentAttach.setContent((FlashContent) dozer.map(flashContent,
				FlashContent.class));
		contentAttach.setContentType(DictionaryStaticValues.CONTENT_FLASH);
		contentAttach.setAttachId(caobj.getAttachId());
		if (ContentStatic.cab == null) {
			ContentStatic.cab = new HashMap<String, ContentAttachBean>();
		}
		ContentStatic.cab.put(contentAttach.getContent().getContentId(), contentAttach);
		return "redirect";
	}

	@Action(value = "contentattach-savevideo", results = { @Result(name = "redirect", location = "/common/upload/contentattach-save.jsp"),@Result(name = "input", location = "/common/upload/error-ajax.jsp") })
	public String savevideo() {
		if (!StringUtils.isNotBlank(videoContent.getContentId())) {
			videoContent.setContentId(null);
			videoContent
					.setContentStatus(DictionaryStaticValues.CONTENT_STATUS_LOCK);
			VideoContent cobj = (VideoContent) dozer.map(videoContent,
					VideoContent.class);
			videoContentService
					.save(cobj,
							(Admin) getSessionValue(ConstantWebApp.CURRENT_ADMIN),
							null);
			videoContent.setContentId(cobj.getContentId());
		} else {
			videoContent = (VideoContentBean) dozer.map(videoContentService
					.getVideoContent(videoContent.getContentId()),
					VideoContentBean.class);
		}
		if (url != null && !url.equals("")) {
			try {
				url = new String(url.getBytes("iso-8859-1"), "utf-8");
			} catch (UnsupportedEncodingException e2) {
				log.info(e2.toString());
			}
			tempUrl = url.substring(url.lastIndexOf("\\") + 1, url.length());
		}
		String fileType = FileUtil.getFileExt(tempUrl);
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMM");
		SimpleDateFormat sdf2 = new SimpleDateFormat("dd");
		contentAttach.setAttachMemo(null);
		contentAttach.setAttachName(tempUrl);
		contentAttach.setAttachExt(fileType);
		contentAttach.setAttachSize((int) (upload.length() / 1024));
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
		Random roll = new Random();
		String savePath = FilePathSptUtil.CONTENT_VIDEO
				+ FilePathSptUtil.padRightAndLeftSpt(sdf1.format(new Date()))
				+ sdf2.format(new Date());
		contentAttach.setAttachUrl(FilePathSptUtil.UPLOAD_ROOT_PATH
				+ FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padRightAndLeftSpt(savePath)
				+ sdf.format(new Date()) + roll.nextInt(10) + "." + fileType);
		contentAttach.setContentAttachRealPath(FilePathSptUtil.UPLOAD_ROOT_PATH
				+ FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padLeftSpt(savePath));
		ContentAttach caobj = (ContentAttach) dozer.map(contentAttach,
				ContentAttach.class);
		caobj.setContent((VideoContent) dozer.map(videoContent,
				VideoContent.class));
		contentAttachService.save(caobj);
		contentAttach.setContent((VideoContent) dozer.map(videoContent,
				VideoContent.class));
		contentAttach.setContentType(DictionaryStaticValues.CONTENT_VIDEO);
		contentAttach.setAttachId(caobj.getAttachId());
		if (ContentStatic.cab == null) {
			ContentStatic.cab = new HashMap<String, ContentAttachBean>();
		}
		ContentStatic.cab.put(contentAttach.getContent().getContentId(), contentAttach);
		return "redirect";
	}

	@Action(value = "contentattach-savesoftware", results = { @Result(name = "redirect", location = "/common/upload/contentattach-save.jsp"),@Result(name = "input", location = "/common/upload/error-ajax.jsp") })
	public String savesoftware() {
		if (!StringUtils.isNotBlank(softwareContent.getContentId())) {
			softwareContent.setContentId(null);
			softwareContent
					.setContentStatus(DictionaryStaticValues.CONTENT_STATUS_LOCK);
			SoftwareContent cobj = (SoftwareContent) dozer.map(softwareContent,
					SoftwareContent.class);
			softwareContentService
					.save(cobj,
							(Admin) getSessionValue(ConstantWebApp.CURRENT_ADMIN),
							null);
			softwareContent.setContentId(cobj.getContentId());
		} else {
			softwareContent = (SoftwareContentBean) dozer.map(
					softwareContentService.getSoftwareContent(softwareContent
							.getContentId()), SoftwareContentBean.class);
		}
		if (url != null && !url.equals("")) {
			try {
				url = new String(url.getBytes("iso-8859-1"), "utf-8");
			} catch (UnsupportedEncodingException e2) {
				log.info(e2.toString());
			}
			tempUrl = url.substring(url.lastIndexOf("\\") + 1, url.length());
		}
		String fileType = FileUtil.getFileExt(tempUrl);
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMM");
		SimpleDateFormat sdf2 = new SimpleDateFormat("dd");
		contentAttach.setAttachMemo(null);
		contentAttach.setAttachName(tempUrl);
		contentAttach.setAttachExt(fileType);
		contentAttach.setAttachSize((int) (upload.length() / 1024));
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
		Random roll = new Random();
		String savePath = FilePathSptUtil.CONTENT_SOFTWARE
				+ FilePathSptUtil.padRightAndLeftSpt(sdf1.format(new Date()))
				+ sdf2.format(new Date());
		String uploadName = sdf.format(new Date()) + roll.nextInt(10) + "." + fileType;
		contentAttach.setUploadName(uploadName);
		contentAttach.setAttachUrl(FilePathSptUtil.UPLOAD_ROOT_PATH
				+ FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padRightAndLeftSpt(savePath)
				+ uploadName);
		contentAttach.setContentAttachRealPath(FilePathSptUtil.UPLOAD_ROOT_PATH
				+ FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padLeftSpt(savePath));
		ContentAttach caobj = (ContentAttach) dozer.map(contentAttach,
				ContentAttach.class);
		caobj.setContent((SoftwareContent) dozer.map(softwareContent,
				SoftwareContent.class));
		contentAttachService.save(caobj);
		contentAttach.setContent((SoftwareContent) dozer.map(softwareContent,
				SoftwareContent.class));
		contentAttach.setContentType(DictionaryStaticValues.CONTENT_SOFTWARE);
		contentAttach.setAttachId(caobj.getAttachId());
		if (ContentStatic.cab == null) {
			ContentStatic.cab = new HashMap<String, ContentAttachBean>();
		}
		ContentStatic.cab.put(contentAttach.getContent().getContentId(), contentAttach);
		return "redirect";
	}

	@Action(value = "contentattach-savesoftwarepic", results = { @Result(name = "redirect", location = "/common/upload/contentattach-savepic.jsp"),@Result(name = "input", location = "/common/upload/error-ajax.jsp") })
	public String savesoftwarepic() {
		SoftwareContent softwarecontent = softwareContentService
				.getSoftwareContent(softwareContent.getContentId());
		softwareContent = (SoftwareContentBean) dozer.map(softwarecontent,
				SoftwareContentBean.class);
		if (url != null && !url.equals("")) {
			try {
				url = new String(url.getBytes("iso-8859-1"), "utf-8");
			} catch (UnsupportedEncodingException e2) {
				log.info(e2.toString());
			}
			tempUrl = url.substring(url.lastIndexOf("\\") + 1, url.length());
		}
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMM");
		SimpleDateFormat sdf2 = new SimpleDateFormat("dd");
		Random roll = new Random();
		String fileName = sdf.format(new Date()) + roll.nextInt(10);
		String fileType = FileUtil.getFileExt(tempUrl);
		String savePath = FilePathSptUtil.CONTENT_SOFTWARE
				+ FilePathSptUtil.padRightAndLeftSpt(sdf1.format(new Date()))
				+ sdf2.format(new Date());
		String dstPath = FilePathSptUtil.UPLOAD_ROOT_PATH
				+ FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padRightAndLeftSpt(savePath) + fileName + "."
				+ fileType;
		File dirFile = new File(FilePathSptUtil.UPLOAD_ROOT_PATH
				+ FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padRightAndLeftSpt(savePath));
		boolean isDir = dirFile.isDirectory();
		if (!isDir) {// 目录不存在则先建目录
			try {
				dirFile.mkdirs();
			} catch (Exception e) {
				log.info(e.toString());
			}
		}
		FileUtil.copyFile(uploadp.getPath(), dstPath);
		String picPath = FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padRightAndLeftSpt(savePath) + fileName + "."
				+ fileType;
		softwareContent.setSoftwarePic(FilePathSptUtil.UPLOAD_URL
				+ picPath.replaceAll("\\\\", "/"));
		return "redirect";
	}

	@Action(value = "contentattach-savepicture", results = { @Result(name = "redirect", location = "/common/upload/contentattach-save.jsp"),@Result(name = "input", location = "/common/upload/error-ajax.jsp") })
	public String savepicture() {
		if (!StringUtils.isNotBlank(pictureContent.getContentId())) {
			pictureContent.setContentId(null);
			pictureContent
					.setContentStatus(DictionaryStaticValues.CONTENT_STATUS_LOCK);
			PictureContent cobj = (PictureContent) dozer.map(pictureContent,
					PictureContent.class);
			pictureContentService
					.save(cobj,
							(Admin) getSessionValue(ConstantWebApp.CURRENT_ADMIN),
							null);
			pictureContent.setContentId(cobj.getContentId());
		} else {
			pictureContent = (PictureContentBean) dozer.map(
					pictureContentService.getPictureContent(pictureContent
							.getContentId()), PictureContentBean.class);
		}
		if ("1".equals(uploadType)) {
			if (url != null && !url.equals("")) {
				try {
					url = new String(url.getBytes("iso-8859-1"), "utf-8");
				} catch (UnsupportedEncodingException e2) {
					log.info(e2.toString());
				}
				tempUrl = url
						.substring(url.lastIndexOf("\\") + 1, url.length());
			}
			String fileType = FileUtil.getFileExt(tempUrl);
			SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMM");
			SimpleDateFormat sdf2 = new SimpleDateFormat("dd");
			contentAttach.setAttachMemo(null);
			contentAttach.setAttachName(tempUrl);
			contentAttach.setAttachExt(fileType);
			contentAttach.setAttachSize((int) (upload.length() / 1024));
			SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
			Random roll = new Random();
			String savePath = FilePathSptUtil.CONTENT_PICTURE
					+ FilePathSptUtil.padRightAndLeftSpt(sdf1
							.format(new Date())) + sdf2.format(new Date());
			String uploadName = sdf.format(new Date()) + roll.nextInt(10) + "." + fileType;
			contentAttach.setUploadName(uploadName);
			String attachUrl = (FilePathSptUtil.UPLOAD_CMS
					+ FilePathSptUtil.padRightAndLeftSpt(savePath)
					+ uploadName)
					.replaceAll("\\\\", "/");
			contentAttach.setAttachUrl(attachUrl);
			contentAttach
					.setContentAttachRealPath(FilePathSptUtil.UPLOAD_ROOT_PATH
							+ FilePathSptUtil.UPLOAD_CMS
							+ FilePathSptUtil.padRightAndLeftSpt(savePath));
			ContentAttach caobj = (ContentAttach) dozer.map(contentAttach,
					ContentAttach.class);
			caobj.setContent((PictureContent) dozer.map(pictureContent,
					PictureContent.class));
			caobj.setAttachType("0");
			caobj.setAttachDownloadNum(ITEM_NUM);
			contentAttachService.save(caobj);
			contentAttach.setContent((PictureContent) dozer.map(pictureContent,
					PictureContent.class));
			contentAttach.setAttachId(caobj.getAttachId());
			contentAttach
					.setContentType(DictionaryStaticValues.CONTENT_PICTURE);
			contentAttach.setAttachUrl(FilePathSptUtil.UPLOAD_ROOT_PATH
					+ attachUrl);
			if (ContentStatic.cab == null) {
				ContentStatic.cab = new HashMap<String, ContentAttachBean>();
			}
			ContentStatic.cab.put(contentAttach.getContent().getContentId(), contentAttach);
			return "redirect";
		} else {
			if (url != null && !url.equals("")) {
				try {
					url = new String(url.getBytes("iso-8859-1"), "utf-8");
				} catch (UnsupportedEncodingException e2) {
					log.info(e2.toString());
				}
				tempUrl = url
						.substring(url.lastIndexOf("\\") + 1, url.length());
			}
			SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMM");
			SimpleDateFormat sdf2 = new SimpleDateFormat("dd");
			SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
			Random roll = new Random();
			String savePath = FilePathSptUtil.CONTENT_PICTURE
					+ FilePathSptUtil.padRightAndLeftSpt(sdf1
							.format(new Date())) + sdf2.format(new Date());
			String dstPath = FilePathSptUtil.UPLOAD_ROOT_PATH
					+ FilePathSptUtil.UPLOAD_CMS
					+ FilePathSptUtil.padLeftSpt(savePath)+FilePathSptUtil.padLeftSpt("temp");
			String newPath = FilePathSptUtil.UPLOAD_ROOT_PATH
					+ FilePathSptUtil.UPLOAD_CMS
					+ FilePathSptUtil.padRightAndLeftSpt(savePath)
					+ sdf.format(new Date()) + roll.nextInt(10) + "."
					+ FileUtil.getFileExt(tempUrl);
			File dirFile = new File(dstPath);
			boolean isDir = dirFile.isDirectory();
			if (!isDir) {// 目录不存在则先建目录
				try {
					dirFile.mkdirs();
				} catch (Exception e) {
					log.info(e.toString());
				}
			}
			FileUtil.copyFile(upload.getPath(), newPath);
			try {
				List<File> list = ZipUtil.doZip(newPath, dstPath, "gbk", new String[]{"jpg","jpeg","png","gif"}, 1024*1024*2);
				//zipToFile(newPath, dstPath);
				for (int i = 0; i < list.size(); i++) {
					String fileType = FileUtil.getFileExt(list.get(i).getName());
					contentAttach.setUploadName(sdf.format(new Date()) + roll.nextInt(10) + "." +fileType);
					String attachUrl = (FilePathSptUtil.UPLOAD_CMS
							+ FilePathSptUtil.padRightAndLeftSpt(savePath) + contentAttach.getUploadName()).replaceAll("\\\\", "/");
					contentAttach.setAttachMemo(null);
					contentAttach.setAttachName(list.get(i).getName());
					contentAttach.setAttachExt(fileType);
					contentAttach.setAttachSize((int) (list.get(i).length() / 1024));
					contentAttach.setAttachUrl(attachUrl);
					contentAttach
							.setContentAttachRealPath(FilePathSptUtil.UPLOAD_ROOT_PATH
									+ FilePathSptUtil.UPLOAD_CMS
									+ FilePathSptUtil.padRightAndLeftSpt(savePath));
					FileUtil.copyFile(list.get(i).getAbsolutePath(), contentAttach.getContentAttachRealPath()+contentAttach.getUploadName());
					ContentAttach caobj = (ContentAttach) dozer.map(contentAttach,
							ContentAttach.class);
					caobj.setContent((PictureContent) dozer.map(pictureContent,
							PictureContent.class));
					caobj.setAttachType("0");
					contentAttachService.save(caobj);
					contentAttach.setContent((PictureContent) dozer.map(
							pictureContent, PictureContent.class));
					doPic(contentAttach.getUploadName(),contentAttach,caobj);
				}
				FileUtil.delFolder(newPath);
				FileUtil.delFolder(dstPath);
				contentAttach
						.setContentType(DictionaryStaticValues.CONTENT_PICTURE);
				contentAttach.setContent(pictureContent);
				if (ContentStatic.cab == null) {
					ContentStatic.cab = new HashMap<String, ContentAttachBean>();
				}
				ContentStatic.cab.put(contentAttach.getContent().getContentId(), contentAttach);
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return "redirect";
		}

	}
	
	/**
	 * 保存上传图片Action
	 */
	@Action(value="save-picture", results = { @Result(name = "redirect", location = "/common/upload/upload-preview.jsp"),@Result(name = "input", location = "/common/upload/error-ajax.jsp") })
	public String savePicture() {
		if(StringUtils.isNotBlank(picturePhysicalPath)) {
			File file = new File(picturePhysicalPath);
			deleteExitsFile(file);
		}
		String fileName = upload(url);
		//图片物理路径
		picturePhysicalPath = FilePathSptUtil.UPLOAD_ROOT_PATH + FilePathSptUtil.UPLOAD_CMS+FilePathSptUtil.URL_SPT+FilePathSptUtil.CMS_LOGO+
				FilePathSptUtil.URL_SPT+DateUtil.formatDateToString(new Date(), "yyyy-MM")+FilePathSptUtil.URL_SPT+fileName;
		//图片在数据库中存放的路径
		pictureDbPath = FilePathSptUtil.UPLOAD_CMS+FilePathSptUtil.URL_SPT+FilePathSptUtil.CMS_LOGO+
					FilePathSptUtil.URL_SPT+DateUtil.formatDateToString(new Date(), "yyyy-MM")+FilePathSptUtil.URL_SPT+fileName;
		//附件信息
		tempUrl = url
				.substring(url.lastIndexOf("\\") + 1, url.length());
		String fileType = FileUtil.getFileExt(tempUrl);
		SimpleDateFormat sdf1 = new SimpleDateFormat("yyyyMM");
		SimpleDateFormat sdf2 = new SimpleDateFormat("dd");
		SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmmss");
		Random roll = new Random();
		String savePath = FilePathSptUtil.CONTENT_PICTURE
				+ FilePathSptUtil.padRightAndLeftSpt(sdf1
						.format(new Date())) + sdf2.format(new Date());
		contentAttach.setAttachMemo(null);
		contentAttach.setAttachName(tempUrl);
		contentAttach.setUploadOriginName(fileName);
		contentAttach.setAttachExt(fileType);
		contentAttach.setAttachSize((int) (upload.length() / 1024));
		String uploadName = sdf.format(new Date()) + roll.nextInt(10) + "." + fileType;
		contentAttach.setUploadName(uploadName);
		String attachUrl = (FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padRightAndLeftSpt(savePath)
				+ uploadName)
				.replaceAll("\\\\", "/");
		contentAttach.setAttachUrl(attachUrl);
		contentAttach
		.setContentAttachRealPath(FilePathSptUtil.UPLOAD_ROOT_PATH
				+ FilePathSptUtil.UPLOAD_CMS
				+ FilePathSptUtil.padRightAndLeftSpt(savePath));
		
		return "redirect";
	}
	
	private String upload(String pic){
		SimpleDateFormat formater = new SimpleDateFormat("yyyyMMddhhmmssSSSS");
		String filename=formater.format(new Date());
		String fileExtend = pic.substring(pic.lastIndexOf(".")+1,pic.length());
		String root= FilePathSptUtil.UPLOAD_ROOT_PATH+FilePathSptUtil.UPLOAD_CMS+SPT+FilePathSptUtil.CMS_LOGO+SPT+DateUtil.formatDateToString(new Date(), "yyyy-MM");
		String fullName=filename+"."+fileExtend;
		String dstPath = root+SPT+fullName;	//全路径
		File dirFile = new File(root);
		boolean isDir = dirFile.isDirectory();
		if(!isDir){//目录不存在则先建目录
			try{
				dirFile.mkdirs();
			}catch (Exception e) {
				File delFile = new File(root
						+SPT +fullName );
				deleteExitsFile(delFile);
			}
		}
		FileUtil.copyFile(upload.getPath(), dstPath);//上传文件
		return fullName;
	}
	
	private  void deleteExitsFile(File file) {
		if(file.exists() && file.isFile()){
			file.delete();
		}
	}
	@Action(value="delete-excessPicture")
	public void deleteExcessPic() {
		File file = new File(picturePhysicalPath);
		deleteExitsFile(file);
	}
	
	@Action("focus")
	public String setFocusPic(){
		try {
			if(StringUtils.isBlank(contentId) || StringUtils.isBlank(attachId))	
				return renderText("{flag:false,msg:'焦点图设置异常'}");
			contentAttachService.setPictureToFocus(contentId, attachId);
			return renderText("{flag:true,msg:'设置成功'}");
		} catch (Exception e) {
			log.error("焦点图设置异常", e);
			return renderText("{flag:false,msg:'焦点图设置异常'}");
		} 
	}

	public String getAttachId() {
		return attachId;
	}

	public void setAttachId(String attachId) {
		this.attachId = attachId;
	}

	public String getContentId() {
		return contentId;
	}

	public void setContentId(String contentId) {
		this.contentId = contentId;
	}

}